package Stdlog::Writer;

use 5.008;
use strict;
use warnings;

sub new {
    my ($pkg, $conf) = @_;
    my ($class, $self);
    eval {
        $class = $conf->{writer};
        $class = 'File'   if exists $conf->{filename};
        $class = 'Socket' if exists $conf->{socket};
        $class = 'DBI'    if exists $conf->{dsn};
        $class = 'STDERR' unless defined $class;
        
        $pkg = "Stdlog/Writer/$class.pm";
        require $pkg;
        $pkg = "Stdlog::Writer::$class";
        $self = $pkg->new($conf);
    };
    if( $@ ){
        die "Couldn't create Stdlog::Writer::$class ($@)\n";
    }
    return $self;
}



sub logmsg {
    my $self = shift @_;
    my $args = shift @_;
    print STDERR "@_\n";
}


1;
__END__

=head1 NAME

Stdlog::Writer - factory for creating Stdlog::Writer::* objects

=head1 SYNOPSIS

  use Stdlog;
  
  

=head1 DESCRIPTION


=head1 CLASS METHODS

=head2 Stdlog::Writer->new(\%conf)


=head1 OBJECT METHODS


=head1 EXPORTS

None by default.


=head1 SEE ALSO


=head1 AUTHOR

Robert Mah E<lt>rmah@pobox.comE<gt>


=head1 COPYRIGHT AND LICENSE

Copyright (C) 2009 by Robert Mah

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.8 or,
at your option, any later version of Perl 5 you may have available.

=cut
